import request from '@/utils/http'

/**
 * 分页查询通知消息
 * @param {Object} params 查询参数
 */
export const getNoticeMessagesApi = (params) => {
  return request.post('/mapi/notice/page', params)
}

/**
 * 获取通知消息统计信息
 */
export const getNoticeMessageStatsApi = () => {
  return request.get('/mapi/notice/stats')
}

/**
 * 获取未读消息数量
 */
export const getUnreadCountApi = () => {
  return request.get('/mapi/notice/unread/count')
}

/**
 * 发送通知消息
 * @param {Object} message 消息对象
 */
export const sendNoticeMessageApi = (message) => {
  return request.post('/mapi/notice/send', message)
}

/**
 * 批量发送通知消息
 * @param {Array} messages 消息数组
 */
export const batchSendNoticeMessagesApi = (messages) => {
  return request.post('/mapi/notice/send/batch', messages)
}

/**
 * 标记消息为已读
 * @param {Number} messageId 消息ID
 */
export const markAsReadApi = (messageId) => {
  return request.put(`/mapi/notice/${messageId}/read`)
}

/**
 * 批量标记消息为已读
 * @param {Array} messageIds 消息ID数组
 */
export const batchMarkAsReadApi = (messageIds) => {
  return request.put('/mapi/notice/read/batch', messageIds)
}

/**
 * 标记所有消息为已读
 */
export const markAllAsReadApi = () => {
  return request.put('/mapi/notice/read/all')
}

/**
 * 删除消息
 * @param {Array} messageIds 消息ID数组
 */
export const deleteMessagesApi = (messageIds) => {
  return request.delete('/mapi/notice/delete', { data: messageIds })
}

/**
 * 测试发送通知（开发用）
 * @param {Number} userId 用户ID
 */
export const testSendNoticeApi = (userId) => {
  return request.get(`/mapi/notice/test/send/${userId}`)
}